#include "ColorSet.h"

using namespace std;

void ColorSet::AttachColor(const Color &c, int32_t importance)
{
    if (importance == 0)
        return;
    auto cp = cm.find(c);
    if (cp == cm.end())
        cm.insert(make_pair(c, importance));
    else
        cm[c] += importance;
    size += importance;
}

list<tuple<Color, int32_t>> ColorSet::ToList() const
{
    auto cl = list<tuple<Color, int32_t>>();
    for (const auto& i : cm)
        cl.emplace_back(tuple(Color(i.first.r, i.first.g, i.first.b, i.first.a), i.second));
    return cl;
}
